package com.itlong.cloud.operate.dao;

import com.itlong.cloud.POJO.PO.PropertyPackagePO;
import com.itlong.cloud.POJO.PO.PropertyRoleFunctionPO;
import com.itlong.cloud.POJO.VO.operate.OperatePropertyAccountDetailVO;
import com.itlong.cloud.POJO.VO.operate.OperatePropertyPackageVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <desc>
 *      运营-套餐管理-物业套餐管理数据访问层
 * </desc>
 *
 * @createDate2020/3/23
 **/
@Mapper
@Repository
public interface IOperatePropertyPackageDao {


    /**
     * <desc>
     *      获取物业套餐列表
     * </desc>
     *
     * @param params 查询参数
     * @return
     * @Author Zhu.yj
     * @createDate  2020/3/24
     */
    List<PropertyPackagePO> getPage(Map<String, Object> params);

    /**
     * <desc>
     *      获取物业套餐列表数量
     * </desc>
     *
     * @param params 查询参数
     * @return
     * @Author Zhu.yj
     * @createDate  2020/3/24
     */
    Integer getPageCount(Map<String, Object> params);

    /**
     * <desc>
     *      更新物业套餐信息
     * </desc>
     *
     * @param params 参数map
     * @return
     * @Author Zhu.yj
     * @createDate  2020/3/24
     */
    Integer update(Map<String, Object> params);

    /**
     * <desc>
     *      保存物业套餐信息
     * </desc>
     *
     * @param params 参数map
     * @return
     * @Author Zhu.yj
     * @createDate  2020/3/24
     */
    Integer save(Map<String, Object> params);

    /**
     * <desc>
     *      批量删除物业套餐
     * </desc>
     *
     * @param propertyPackageIds 物业套餐id，多个逗号隔开
     * @return
     * @Author Zhu.yj
     * @createDate  2020/3/24
     */
    Integer delete(@Param("ids") String[] propertyPackageIds);

    /**
     * <desc>
     *      获取物业套餐绑定的账号
     * </desc>
     *
     * @param propertyPackageId 套餐id
     * @return
     * @Author Zhu.yj
     * @createDate  2020/3/24
     */
    List<Map<String, Object>> getPropertyPackageAccount(@Param("propertyPackageId") String propertyPackageId);

    /**
     * <desc>
     *      获取用户账号下的套餐列表
     * </desc>
     *
     * @return
     * @Author Zhu.yj
     * @createDate  2020/3/25
     */
    List<OperatePropertyPackageVO> getPackage(@Param("projectId") String projectId);

    /**
     * <desc>
     *      套餐分配功能
     * </desc>
     *
     * @param appFunctionIds 功能id数组
     * @param appPackageId 套餐id
     * @return
     * @author Zhu.yj
     * @createDate  2020/3/25
     */
    Integer allotFunction(@Param("propertyFunctionIds")List<String> appFunctionIds,
                          @Param("propertyPackageId")String appPackageId,
                          @Param("status")Integer status,
                          @Param("createTime") Date createTime);

    /**
     * <desc>
     *      删除套餐功能
     * </desc>
     *
     * @param propertyPackageId 物业套餐id
     * @return
     * @Author Zhu.yj
     * @createDate  2020/3/25
     */
    Integer deleteFunctions(@Param("propertyPackageIds") String[] propertyPackageId);

    /**
     * <desc>
     *      删除套餐关联的用户
     * </desc>
     *
     * @param propertyPackageId 套餐id
     * @param userId 用户id
     * @return
     * @Author Zhu.yj
     * @createDate  2020/3/26
     */
    Integer deletePackageUser(@Param("propertyPackageId") String propertyPackageId,@Param("userId") String userId);

    /**
     * <desc>
     *      套餐分配用户
     * </desc>
     *
     * @param propertyPackageId 套餐id
     * @param userIds 要分配的用户id数组
     * @return
     * @Author Zhu.yj
     * @createDate  2020/3/26
     */
    Integer allotPackageUser(@Param("propertyPackageId") String propertyPackageId,
                              @Param("userIds") String[] userIds,
                              @Param("status") Integer status,
                              @Param("createTime") Date createTime);

    /**
     * <desc>
     *      获取单个物业套餐信息
     * </desc>
     *
     * @param propertyPackageId 物业套餐id
     * @return  单个物业套餐详细信息
     * @Author Zhu.yj
     * @createDate  2020/4/1
     */
    PropertyPackagePO getOne(@Param("propertyPackageId") String propertyPackageId);

    /**
     * <desc>
     *      获取绑定了套餐的用户列表
     * </desc>
     *
     * @param propertyPackageId 物业套餐id
     * @return
     * @Author Zhu.yj
     * @createDate  2020/4/3
     */
    List<String> getOther(@Param("propertyPackageId") String propertyPackageId);

    /**
     * <desc>
     *      删除套餐关联的用户id
     * </desc>
     *
     * @param propertyPackageId 物业套餐id
     * @param allotUserIds 套餐关联的用户id
     * @return
     * @Author Zhu.yj
     * @createDate  2020/4/3
     */
    Integer deletePackageAccount(@Param("propertyPackageId") String propertyPackageId,
                                 @Param("userIds") String[] allotUserIds);

    /**
     * <desc>
     *      根据套餐id删除套餐关联的用户
     * </desc>
     *
     * @param propertyPackageIds 套餐id列表
     * @return
     * @Author Zhu.yj
     * @createDate  2020/4/9
     */
    Integer deleteByPackageIds(@Param("propertyPackageIds") String[] propertyPackageIds);

    /**
     * <desc>
     *      更新套餐操作时间
     * </desc>
     *
     * @param params 参数map
     * @return
     * @Author Zhu.yj
     * @createDate  2020/4/9
     */
    Integer updateOperateTime(Map<String, Object> params);

    /**
     * <desc>
     *      获取套餐
     * </desc>
     *
     * @param appPackageId 套餐id
     * @return
     * @Author Zhu.yj
     * @createDate  2020/4/17
     */
    List<String> getFunctionIds(@Param("appPackageId")String  appPackageId);

    /**
     * <desc>
     *      获取物业账号的角色及管辖项目
     * </desc>
     *
     * @param
     * @return
     * @Author Zhu.yj
     * @createDate  2020/4/17
     */
    OperatePropertyAccountDetailVO getDetail(@Param("userId") String userId);

    /**
     * <desc>
     *      删除角色项目菜单
     * </desc>
     *
     * @param projectIds 项目id数组
     * @return
     * @Author Zhu.yj
     * @createDate  2020/4/17
     */
    Integer removeRoleProjectFunction(@Param("projectIds") List<Map<String, Object>> projectIds);

    /**
     * <desc>
     *      保存角色项目功能菜单
     * </desc>
     *
     * @param propertyRoleFunctionPOS 物业角色功能列表
     * @return
     * @Author Zhu.yj
     * @createDate  2020/4/17
     */
    Integer saveRoleProjectFunction(List<PropertyRoleFunctionPO> propertyRoleFunctionPOS);

    /**
     * <desc>
     *      通过用户id获取套餐id
     * </desc>
     *
     * @param userId 用户id
     * @return 套餐id列表
     * @Author Zhu.yj
     * @createDate  2020/9/11
     */
    List<String> getPackageIdByUserId(@Param("userId") String userId);

    /**
     * <desc>
     *      删除非物业管理员不应有的菜单权限
     * </desc>
     *
     * @param propertyRoleFunctionPOS
     * @return
     * @Author Zhu.yj
     * @createDate  2021/3/25
     */
    Integer removeOtherPropertyFunction(@Param("list") List<PropertyRoleFunctionPO> propertyRoleFunctionPOS);
}